home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / gengui2.lha / GenGui2 / Examples / jumpwin.c < prev    next >
C/C++ Source or Header  |  1995-02-14  |  4KB  |  114 lines

  1. #include <stdlib.h>
  2. #include <proto/intuition.h>
  3. #include <intuition/intuition.h>
  4. #include <proto/exec.h>
  5. #include <proto/graphics.h>
  6.  
  7. #include "jumpwin.h"
  8.  
  9. extern struct IntuitionBase *IntuitionBase;
  10. extern struct GfxBase *GfxBase;
  11. extern struct Library *GadToolsBase;
  12.  
  13. main()
  14. {
  15.    struct IntuiMessage *msg;
  16.    struct Window *win[2];
  17.    struct TextFont *font=NULL;
  18.  
  19.    int a;
  20.    int run=1;
  21.  
  22.    win[0]=OpenWindowTags(NULL,
  23.             WA_Left,0,WA_Top,20,
  24.             WA_Width,300,WA_Height,100,
  25.             WA_Title,"Window 1",
  26.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  27.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  28.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  29.                         |WFLG_SIMPLE_REFRESH
  30.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  31.             WA_MinWidth,300,WA_MinHeight,100,
  32.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  33.             TAG_DONE );
  34.  
  35.    win[1]=OpenWindowTags(NULL,
  36.             WA_Left,320,WA_Top,50,
  37.             WA_Width,300,WA_Height,150,
  38.             WA_Title,"Window 2",
  39.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  40.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  41.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  42.                         |WFLG_SIMPLE_REFRESH
  43.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  44.             WA_MinWidth,300,WA_MinHeight,100,
  45.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  46.             TAG_DONE );
  47.  
  48.    if(!win[0] || !win[1]) {
  49.       if(win[0]) CloseWindow(win[0]);
  50.       if(win[1]) CloseWindow(win[1]);
  51.       exit(EXIT_FAILURE);
  52.    }
  53.  
  54.    if(GG_SmartRenderGui(win[0],&JumpGui,&font)) {CloseWindow(win[0]);exit(0);}
  55.  
  56.    while(run) {
  57.       Wait((1<<win[0]->UserPort->mp_SigBit)|
  58.            (1<<win[1]->UserPort->mp_SigBit));
  59.  
  60.       for(a=0;a<2;a++) {
  61.  
  62.          if(win[a]==JumpGui.Window) {
  63.  
  64.             while(msg=GG_GetIMsg(win[a]->UserPort)) {
  65.  
  66.                switch(msg->Class) {
  67.                   case IDCMP_CLOSEWINDOW: run=0;
  68.                                           break;
  69.                   case IDCMP_NEWSIZE:     GG_ResizeGui(&JumpGui);
  70.                                           break;
  71.                   case IDCMP_REFRESHWINDOW:
  72.                                           GG_RefreshGui(&JumpGui);
  73.                                           break;
  74.                   case IDCMP_GADGETUP:
  75.  
  76.                         switch(GetGadget(msg)->GadgetID) {
  77.                            case WIN0:  GG_StopGui(&JumpGui);
  78.                                        GG_SmartRenderGui(win[0],&JumpGui,&font);
  79.                                        GG_ClearWindow(win[1]);
  80.                                        break;
  81.                            case WIN1:  GG_StopGui(&JumpGui);
  82.                                        GG_SmartRenderGui(win[1],&JumpGui,&font);
  83.                                        GG_ClearWindow(win[0]);
  84.                                        break;
  85.                            case OK:
  86.                            case CANCEL: run=0;
  87.                                        break;
  88.                            case FORGET:
  89.                                        GG_FreeGui(&JumpGui);
  90.                                        GG_SmartRenderGui(win[a],&JumpGui,&font);
  91.                                        break;
  92.                         }
  93.                         break;
  94.                }
  95.             }
  96.             GG_ReplyIMsg(msg);
  97.          } else {
  98.             while(msg=(void *)GetMsg(win[a]->UserPort)) ReplyMsg((void *)msg);
  99.          }
  100.  
  101.       }
  102.    }
  103.  
  104.    GG_FreeGui(&JumpGui);
  105.  
  106.    CloseWindow(win[0]);
  107.    CloseWindow(win[1]);
  108.    if(font) CloseFont(font);
  109.    return(0);
  110. }
  111.  
  112.  
  113.  
  114.